package net.xrkw.server.module.client.controller.web;


import net.xrkw.server.module.client.service.index.IndexService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;

@Controller
@ControllerAdvice
public class IndexController {
    @Resource
    private IndexService indexService;

    @PermitAll
    @GetMapping("/")
    public String index(Model model) {
        indexService.getIndexData(model);
        return "index";
    }

    @PermitAll
    @GetMapping("/details/{id}")
    public String softDetail(@PathVariable Long id, Model model) {
        indexService.getSoftDetailData(id, model);
        return "details";
    }

    @PermitAll
    @GetMapping("/download/{id}")
    public String downloadSoft(@PathVariable Long id) {
        return "redirect:/";
    }

}
